using System;
using System.Collections.Generic;
using Kimgwajang.MidnightPeach.Schema;

namespace Kimgwajang.MidnightPeach.Generators
{
    internal class ColumnGenerator : Generator
    {
        private readonly Column _column;

        public ColumnGenerator(SortedDictionary<string, string> variables, Column column)
            : base(variables)
        {
            _column = column;
        }

        internal override string Generate(Macro macro, string text)
        {
            switch (macro.Value)
            {
                case "PascalName":
                    return _column.PascalName;

                case "CamelName":
                    return _column.CamelName;

                case "DbName":
                    return _column.DbName;

                case "Type":
                    return _column.Type;

                case "DbType":
                    return _column.DbType;

                case "BeginCommentIfReadOnly":
                    return _column.ReadOnly ? "/* not available for ReadOnly column" : string.Empty;

                case "EndCommentIfReadOnly":
                    return _column.ReadOnly ? "*/" : string.Empty;

                default:
                    throw new UnsupportedMacroException(macro, text, this);
            }
        }
    }
}